// 获取当天日期的后n天日期
function getFutureDate(n) {
	let today = new Date();
	let futureDate = new Date(today.getTime() + (n * 24 * 60 * 60 * 1000));
	let year = futureDate.getFullYear();
	let month = (futureDate.getMonth() + 1).toString().padStart(2, '0'); // padStart()方法在月份和日期不足两位数时填充0
	let day = futureDate.getDate().toString().padStart(2, '0');
	return year + '-' + month + '-' + day;
}

//获取星期几
function getWeekDate(val) {
	var date = new Date(val);
	var day = date.getDay();
	var names = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
	return names[day];
}


// 获取当前时间
function getNowTime(isAll) {
	let now = new Date();
	let year = now.getFullYear(); //获取完整的年份(4位,1970-????)
	let month = now.getMonth() + 1; //获取当前月份(0-11,0代表1月)
	let today = now.getDate(); //获取当前日(1-31)
	let hour = now.getHours(); //获取当前小时数(0-23)
	let minute = now.getMinutes(); //获取当前分钟数(0-59)
	let second = now.getSeconds(); //获取当前秒数(0-59)
	let nowTime = ''
	//返回年月日时分秒
	if (isAll) {
		nowTime = year + '-' +fillZero(month) + '-' + fillZero(today) + ' ' + fillZero(hour) + ':' +
			fillZero(minute) + ':' +fillZero(second)
	} else { //返回年月日
		nowTime = year + '-' + fillZero(month) + '-' +fillZero(today)
	}
	return nowTime
}


// 给时间补零
function fillZero(str) {
	var realNum;
	if (str < 10) {
		realNum = '0' + str;
	} else {
		realNum = str;
	}
	return realNum;
}

export {
	getFutureDate,
	getWeekDate,
	getNowTime
}